<?php
/**
 * 提取文章出现的高频词
 **/
class KeywordsController extends AppController
{
	var $name = "Keywords";
	var $autoLayout = false;
	var $autoRender = false;
	var $uses = array();
	function index()
	{
		if(isset($_POST['title']) and isset($_POST['content'])){
			// echo ("http://localhost:8000/?title=".urlencode($_GET['title'])."&content=".urlencode($_GET['content']));
			ob_start();
			$title = iconv("utf-8","gbk//IGNORE",$_POST['title']);
			$content = iconv("utf-8","gbk//IGNORE",$_POST['content']);
			$ch = curl_init("http://localhost:8000/?title=".urlencode($title)."&content=".urlencode($content));
			// curl_setopt($ch, CURLOPT_HEADER, 0);
			curl_exec($ch);
			curl_close($ch);
			$result = ob_get_contents();
			ob_end_clean();
			$result = iconv("gbk","utf-8//IGNORE",$result);
			if(count($result)<30){
				echo $result;
				return;
			}
			// str_split($result,)
			// echo '测试标签1 测试标签2 测试标签3';
		}
		echo '0';
		
	}
}
?>
